#!/bin/sh
MODULE_XML=
L4_PROTO=
L7_PROTO=
VERSION=
COMPATIBLE=
FILENAME_SO=

# 获取参数
if [ $# -lt 5 ]; then
        echo -e "sh $0 MODULE_XML L4_PROTO L7_PROTO VERSION COMPATIBLE FILENAME_SO\r\n"
        echo "eg."
        echo "  sh $0 ../../dist/conf/modules/80/2.0/module.xml tcp 80 2.0 2.x http_2.0.so"
        exit
fi

MODULE_XML=$1
L4_PROTO=$2
L7_PROTO=$3
VERSION=$4
COMPATIBLE=$5
FILENAME_SO=$6

if [ -f ${MODULE_XML} ]; then 
	# 
	sed  -i "/^<module/{s/\$L7_PROTO/$L7_PROTO/g;s/\$VERSION/$VERSION/g;s/\$COMPATIBLE/$COMPATIBLE/g}" ${MODULE_XML};
	sed  -i "s/\$L4_PROTO/$L4_PROTO/g" ${MODULE_XML};
	sed  -i "s/\$FILENAME_SO/$FILENAME_SO/g" ${MODULE_XML};

	# echo "sed  -i \"s/\\\$L7_PROTO/$L7_PROTO/g\" ${MODULE_XML};" > ./a001.sh ; 
	# echo "sed  -i \"s/\\\$VERSION/$VERSION/g\" ${MODULE_XML};" >> ./a001.sh ;  
	# echo "sed  -i \"s/\\\$COMPATIBLE/$VERSION/g\" ${MODULE_XML};" >> ./a001.sh ;
	# echo "sed  -i \"s/\\\$FILENAME_SO/$FILENAME_SO/g\" ${MODULE_XML};" >> ./a001.sh ;
	# sh ./a001.sh
	# rm -f ./a001.sh
fi;

